flushTable("http://139.199.200.112/dtpr/index.php?exam-teach-questions-myexamset",JSON.stringify({page:"1"}),".p-page",".table tbody");

//给表格增加一行
function addLine(data,url) {
    var tbody=$("tbody");
    var line=$("<tr>\n" +
        "    <td>"+data.id+"</td>\n" +
        "    <td>"+data.exam+"</td>\n" +
        "    <td>"+data.subject+"</td>\n" +
        "    <td>"+data.volume+"</td>\n" +
        "    <td>"+data.section+"</td>\n" +
        "    <td class='switch'><input type='checkbox' data-toggle='switch'></td>\n" +
        "</tr>");

    if(data.isshare==1){
        line.find("input").attr("checked","checked");
    }

    var input=line.find("input[type='checkbox']");

    input.bootstrapSwitch('onSwitchChange',changeShare);

    tbody.append(line);
}

//改变分享状态
function changeShare() {
    var input=$(this).parents("tr").find("input[type='checkbox']");
    var isshare;
    var id=$($(this).parents("tr").find("td")[0]).text();

    if(input.attr("checked")){
        input.attr("checked",false);
        isshare=0;
    }else {
        input.attr("checked",true);
        isshare=1;
    }

    var json={"isshare":isshare,"id":id};

    console.log(json);

    $.get("http://139.199.200.112/dtpr/index.php?exam-teach-questions-share",json)
}

//设置分享与否
function share() {
    var id=$(this).parent("tr").attr("id");
    if($(this)[0].checked===true){

    }else {

    }
}